
/*

懒汉式 设计模式
 */

public class SingleTon2 {
    public static void main(String[] args) {
        Fruit fruit1 = Fruit.getInstance();
        Fruit fruit2 = Fruit.getInstance();
        System.out.println(fruit1 == fruit2);
    }
}


class Fruit{
    private Fruit(){

    }

    private static Fruit apple = null;

    public  static Fruit getInstance(){
        if (apple==null){
            apple = new Fruit();

        }
        return apple;
    }

}